"""
用于在工具和推理步骤之间共享信息的上下文管理器。
"""

from typing import Any, Dict, Optional
from pydantic import BaseModel, Field


class ToolContext(BaseModel):
    """工具调用的上下文信息"""
    tool_name: str
    input_data: Any
    output_data: Any
    success: bool
    error_message: Optional[str] = None
    execution_time: float = 0.0
    importance: float = 0.7
    metadata: Optional[Dict[str, Any]] = None


class ReasoningStep(BaseModel):
    """推理过程中的一个步骤."""
    step_number: int
    thought: str
    planned_action: Optional[str] = None
    action_input: Optional[Any] = None
    tool_context: Optional[ToolContext] = None
    observation: Optional[str] = None
    confidence: float = 0.5
    metadata: Optional[Dict[str, Any]] = None
